home *** CD-ROM | disk | FTP | other *** search
Text File | 2000-10-06 | 7.0 KB | 248 lines | [TEXT/CWIE] |
- ///--------------------------------------------------------------------------------------
- // SpriteFrame.h
- //
- // Portions are copyright: © 1991-94 Tony Myles, All rights reserved worldwide.
- ///--------------------------------------------------------------------------------------
-
-
- #ifndef __SPRITEFRAME__
- #define __SPRITEFRAME__
-
-
- #ifndef __QDOFFSCREEN__
- #include <QDOffscreen.h>
- #endif
-
- #ifndef __SWCOMMON__
- #include <SWCommonHeaders.h>
- #endif
-
- #ifndef __BLITPIXIEINTERFACE__
- #include <BlitPixieInterface.h>
- #endif
-
- typedef RLEPixelDataHdl RLETokenHandle;
- typedef Ptr RLETokenPtr;
-
- typedef Handle CompiledHandle;
- typedef Ptr CompiledPtr;
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=mac68k
- #endif
-
- ///--------------------------------------------------------------------------------------
- // frame macros
- ///--------------------------------------------------------------------------------------
-
- #define SWGetPixBaseAddr(pm) GetPixBaseAddr(pm) // ((**pm).baseAddr)
- #define SWGetPixRowBytes(pm) ((**pm).rowBytes & 0x3FFF) // GetPixRowBytes(pm)
- #define SWGetPixBitDepth(pm) ((**pm).pixelSize)
-
- ///--------------------------------------------------------------------------------------
- // frame data structure
- ///--------------------------------------------------------------------------------------
-
- struct FrameRec
- {
- CGrafPtr framePort; // GWorld/CPort for the frame image
- GDHandle frameDevice; // GDevice for the frame image
- PixMapHandle framePixHndl; // PixMap for the frame image
- PixMapPtr framePix; // pointer color pix map (valid only while locked)
-
- char* frameBaseAddr; // base address of pixel data (valid only while locked)
- unsigned long frameRowBytes; // number of bytes in a row of the frame
- short leftAlignFactor; // used to align rect.left to the nearest long word
- short rightAlignFactor; // used to align rect.right to the nearest long word
-
- Boolean isFrameLocked; // has the frame been locked?
- Boolean isWindowFrame; // is this a window Frame?
- Boolean interlacingIsOn; // skip every other line?
- Boolean skipOddLines; // skip odd lines (true), or even lines (false)?
-
- short frameDepth; // frame image pixel size
- Rect frameRect; // source image rectangle
- short hotSpotH; // horizontal hot point for this frame
- short hotSpotV; // vertical hot point for this frame
- Rect collisionInset; // if used, makes the collision rect smaller/large for this frame
-
- Point offsetPoint; // offset for this Frame's maskRgn - used when calling OffsetRgn just before drawing the Sprite.
- RgnHandle maskRgn; // image masking region, or NULL
-
- CGrafPtr maskPort; // GWorld/CPort for the mask image
- GDHandle maskDevice; // GDevice for the mask image
- PixMapHandle maskPixHndl; // PixMap for the mask image
- PixMapPtr maskPix; // pointer to color pix map (valid only while locked)
-
- char* maskBaseAddr; // base address of mask pixel data (valid only while locked)
- Boolean tileMaskIsSolid;// used by SWDrawTilesAboveSprite
- Boolean sharesGWorld; // shares GWorld with other frames
- Boolean usesCollisionInset; // True if a collisionInset is used.
- char pad;
-
- unsigned short useCount; // number of sprites using this frame
- short worldRectOffset; // non-whole-byte offset for all-bit blitter
-
- unsigned short numScanLines; // number of scan lines
- unsigned short pixelShift; // amount to left-shift pixels to get bytes
- unsigned long* scanLinePtrArray; // array of offsets to each scanline
-
- RLETokenHandle rleDataH; // handle to RLE token data (shared by all sprite's frames)
- RLETokenPtr rleTokenStart; // start of this frame's tokens (valid only while locked)
-
- #if SW_68K
- CompiledHandle pixCodeH; // handle to compiled sprite data
- CompiledPtr frameBlitterP; // procPtr to draw compiled sprite (valid only while locked)
- #endif
-
- long userData; // reserved for user
- };
-
-
- ///--------------------------------------------------------------------------------------
- // frame flags constants
- ///--------------------------------------------------------------------------------------
-
- typedef enum
- {
- kNoMask = 0,
- kPixelMask = 1,
- kRegionMask = 2,
- kFatMask = (kPixelMask + kRegionMask),
- kSolidMask = 4
- } MaskType;
-
- // Definitions for use with SWCreateFrame
- #define kCreateGWorld true
- #define kDontCreateGWorld false
-
- // Definitions for use with SWSetFrameInterlacingMode
- #define kSkipOddLines true
- #define kSkipEvenLines false
-
-
- ///--------------------------------------------------------------------------------------
- // frame function prototypes
- ///--------------------------------------------------------------------------------------
-
- SW_FUNC OSErr SWCreateFrame(
- GDHandle theGDH,
- FramePtr* newFrameP,
- Rect* frameRect,
- short depth,
- Boolean createGWorld);
-
- SW_FUNC OSErr SWCreateWindowFrame(
- CWindowPtr srcWindowP,
- FramePtr* newFrameP,
- Rect* frameRect,
- short maxHeight);
-
- SW_FUNC OSErr SWCreateFrameFromCicnResource(
- SpriteWorldPtr destSpriteWorld,
- FramePtr* newFrameP,
- short iconResID,
- MaskType maskType);
-
- SW_FUNC OSErr SWCreateFrameFromPictResource(
- SpriteWorldPtr destSpriteWorld,
- FramePtr* newFrameP,
- short pictResID,
- short maskResID,
- MaskType maskType);
-
- SW_FUNC OSErr SWCreateFrameFromGWorldAndRect(
- FramePtr* newFrameP,
- GWorldPtr pictGWorld,
- GWorldPtr maskGWorld,
- Rect* frameRect,
- MaskType maskType);
-
- SW_FUNC OSErr SWCreateFrameFromGWorldAndRectStart(
- GWorldPtr *tempMaskGWorld,
- short maxWidth,
- short maxHeight,
- MaskType maskType);
-
- SW_FUNC OSErr SWCreateFrameFromGWorldAndRectPartial(
- FramePtr* newFrameP,
- GWorldPtr pictGWorld,
- GWorldPtr maskGWorld,
- GWorldPtr tempMaskGWorld,
- Rect* frameRect,
- MaskType maskType);
-
- SW_FUNC void SWCreateFrameFromGWorldAndRectFinish(
- GWorldPtr tempMaskGWorld);
-
- SW_FUNC Boolean SWDisposeFrame(
- FramePtr *oldFramePP);
-
- SW_FUNC void SWDisposeWindowFrame(
- FramePtr *oldFramePP);
-
- SW_FUNC void SWSetPortToFrame(
- FramePtr dstFrameP);
-
- SW_FUNC Boolean SWAlignFrameToWindow(
- FramePtr dstFrameP,
- FramePtr windowFrameP);
-
- SW_FUNC void SWInitializeFrame(
- FramePtr tempFrameP);
-
- SW_FUNC void SWSetFrameMaskRgn(
- FramePtr srcFrameP,
- RgnHandle maskRgn);
-
- SW_FUNC void SWSetFrameHotSpot(
- FramePtr srcFrameP,
- short hotSpotH,
- short hotSpotV);
-
- SW_FUNC void SWSetFrameCollisionInset(
- FramePtr srcFrameP,
- short leftInset,
- short topInset,
- short rightInset,
- short bottomInset);
-
- SW_FUNC void SWSetFrameInterlacingMode(
- FramePtr dstFrameP,
- Boolean skipEveryOtherLine,
- Boolean skipOddLines);
-
- SW_FUNC OSErr SWCopyFrame(
- SpriteWorldPtr destSpriteWorldP,
- FramePtr oldFrameP,
- FramePtr *newFrameP,
- Boolean copyMasks);
-
- SW_FUNC OSErr SWUpdateFrameMasks(
- FramePtr srcFrameP);
-
- SW_FUNC void SWLockFrame(
- FramePtr srcFrameP);
-
- SW_FUNC void SWUnlockFrame(
- FramePtr srcFrameP);
-
- SW_FUNC void SWLockWindowFrame(
- FramePtr windowFrameP);
-
- SW_FUNC void SWUnlockWindowFrame(
- FramePtr windowFrameP);
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=reset
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* __SPRITEFRAME__ */